// MESSAGE ATTITUDE_BODY support class

#pragma once

namespace mavlink {
namespace fppa {
namespace msg {

/**
 * @brief ATTITUDE_BODY message
 *
 * The attitude in the aeronautical frame (right-handed, Z-down, X-front, Y-right).
 */
struct ATTITUDE_BODY : mavlink::Message {
    static constexpr msgid_t MSG_ID = 12;
    static constexpr size_t LENGTH = 185;
    static constexpr size_t MIN_LENGTH = 185;
    static constexpr uint8_t CRC_EXTRA = 105;
    static constexpr auto NAME = "ATTITUDE_BODY";


    uint64_t time_boot_ms; /*< [ms] Timestamp (time since system boot). */
    float roll; /*< [rad] Roll angle (-pi..+pi) */
    float pitch; /*< [rad] Pitch angle (-pi..+pi) */
    float yaw; /*< [rad] Yaw angle (-pi..+pi) */
    float roll_speed; /*< [rad/s] Roll angular speed */
    float pitch_speed; /*< [rad/s] Pitch angular speed */
    float yaw_speed; /*< [rad/s] Yaw angular speed */
    float roll_observed; /*< [deg] Roll observed value (-180..180) */
    float pitch_observed; /*< [deg] Pitch observed value (-90..90) */
    float yaw_observed_mag; /*< [deg] Yaw observed value (-180..180) */
    float yaw_observed_rtk; /*< [deg] Yaw observed value (-180..180) */
    float roll_obs_sub_pred; /*< [deg]  Error between roll angle observed value and prediction value (-180..180) */
    float pitch_obs_sub_pred; /*< [deg] Error between pitch angle observed value and prediction value (-90..90) */
    float yaw_obs_sub_pred; /*< [deg]  Error between yaw angle observed value and prediction value (-180..180) */
    float gyro_x_bia; /*< [deg] X axis gyroscope bias value in body frame (-180..180) */
    float gyro_y_bia; /*< [deg] Y axis gyroscope bias value in body frame (-180..180) */
    float gyro_z_bia; /*< [deg] Z axis gyroscope bias value in body frame (-180..180) */
    float ba_x; /*< [deg/s/s] x axis acceleration value in body frame (-180..180) */
    float ba_y; /*< [deg/s/s] y axis acceleration value in body frame (-180..180) */
    float ba_z; /*< [deg/s/s] z axis acceleration value in body frame (-180..180) */
    float ba_x_obs; /*< [deg/s/s] x axis acceleration observe value in body frame (-180..180) */
    float ba_y_obs; /*< [deg/s/s] y axis acceleration observe value in body frame (-180..180) */
    float ba_z_obs; /*< [deg/s/s] z axis acceleration observe value in body frame (-180..180) */
    float ba_x_bia; /*< [deg/s/s] X axis acceleration bias value in body frame (-30..30) */
    float ba_y_bia; /*< [deg/s/s] Y axis acceleration bias value in body frame (-30..30) */
    float ba_z_bia; /*< [deg/s/s] Z axis acceleration bias value in body frame (-30..30) */
    float bm_x; /*< [mgauss] x axis mgauss value in body frame (-1000..1000) */
    float bm_y; /*< [mgauss] y axis mgauss value in body frame (-1000..1000) */
    float bm_z; /*< [mgauss] z axis mgauss value in body frame (-1000..1000) */
    float bm_x_obs; /*< [mgauss] x axis mgauss observe value in body frame (-1000..1000) */
    float bm_y_obs; /*< [mgauss] y axis mgauss observe value in body frame (-1000..1000) */
    float bm_z_obs; /*< [mgauss] z axis mgauss observe value in body frame (-1000..1000) */
    float bm_x_bia; /*< [mgauss] X axis magnetometer bias value in body frame (-1000..1000) */
    float bm_y_bia; /*< [mgauss] Y axis magnetometer bias value in body frame (-1000..1000) */
    float bm_z_bia; /*< [mgauss] Z axis magnetometer bias value in body frame (-1000..1000) */
    uint32_t time_used; /*<  fusion time */
    uint8_t static_flag; /*<  Flag of body state. 0:body is moving 1:body is static */
    float reserve1; /*<  reserve1 */
    float reserve2; /*<  reserve2 */
    float reserve3; /*<  reserve3 */
    float reserve4; /*<  reserve4 */
    float reserve5; /*<  reserve5 */
    float reserve6; /*<  reserve6 */
    float reserve7; /*<  reserve7 */
    float reserve8; /*<  reserve8 */
    float reserve9; /*<  reserve9 */


    inline std::string get_name(void) const override
    {
            return NAME;
    }

    inline Info get_message_info(void) const override
    {
            return { MSG_ID, LENGTH, MIN_LENGTH, CRC_EXTRA };
    }

    inline std::string to_yaml(void) const override
    {
        std::stringstream ss;

        ss << NAME << ":" << std::endl;
        ss << "  time_boot_ms: " << time_boot_ms << std::endl;
        ss << "  roll: " << roll << std::endl;
        ss << "  pitch: " << pitch << std::endl;
        ss << "  yaw: " << yaw << std::endl;
        ss << "  roll_speed: " << roll_speed << std::endl;
        ss << "  pitch_speed: " << pitch_speed << std::endl;
        ss << "  yaw_speed: " << yaw_speed << std::endl;
        ss << "  roll_observed: " << roll_observed << std::endl;
        ss << "  pitch_observed: " << pitch_observed << std::endl;
        ss << "  yaw_observed_mag: " << yaw_observed_mag << std::endl;
        ss << "  yaw_observed_rtk: " << yaw_observed_rtk << std::endl;
        ss << "  roll_obs_sub_pred: " << roll_obs_sub_pred << std::endl;
        ss << "  pitch_obs_sub_pred: " << pitch_obs_sub_pred << std::endl;
        ss << "  yaw_obs_sub_pred: " << yaw_obs_sub_pred << std::endl;
        ss << "  gyro_x_bia: " << gyro_x_bia << std::endl;
        ss << "  gyro_y_bia: " << gyro_y_bia << std::endl;
        ss << "  gyro_z_bia: " << gyro_z_bia << std::endl;
        ss << "  ba_x: " << ba_x << std::endl;
        ss << "  ba_y: " << ba_y << std::endl;
        ss << "  ba_z: " << ba_z << std::endl;
        ss << "  ba_x_obs: " << ba_x_obs << std::endl;
        ss << "  ba_y_obs: " << ba_y_obs << std::endl;
        ss << "  ba_z_obs: " << ba_z_obs << std::endl;
        ss << "  ba_x_bia: " << ba_x_bia << std::endl;
        ss << "  ba_y_bia: " << ba_y_bia << std::endl;
        ss << "  ba_z_bia: " << ba_z_bia << std::endl;
        ss << "  bm_x: " << bm_x << std::endl;
        ss << "  bm_y: " << bm_y << std::endl;
        ss << "  bm_z: " << bm_z << std::endl;
        ss << "  bm_x_obs: " << bm_x_obs << std::endl;
        ss << "  bm_y_obs: " << bm_y_obs << std::endl;
        ss << "  bm_z_obs: " << bm_z_obs << std::endl;
        ss << "  bm_x_bia: " << bm_x_bia << std::endl;
        ss << "  bm_y_bia: " << bm_y_bia << std::endl;
        ss << "  bm_z_bia: " << bm_z_bia << std::endl;
        ss << "  time_used: " << time_used << std::endl;
        ss << "  static_flag: " << +static_flag << std::endl;
        ss << "  reserve1: " << reserve1 << std::endl;
        ss << "  reserve2: " << reserve2 << std::endl;
        ss << "  reserve3: " << reserve3 << std::endl;
        ss << "  reserve4: " << reserve4 << std::endl;
        ss << "  reserve5: " << reserve5 << std::endl;
        ss << "  reserve6: " << reserve6 << std::endl;
        ss << "  reserve7: " << reserve7 << std::endl;
        ss << "  reserve8: " << reserve8 << std::endl;
        ss << "  reserve9: " << reserve9 << std::endl;

        return ss.str();
    }

    inline void serialize(mavlink::MsgMap &map) const override
    {
        map.reset(MSG_ID, LENGTH);

        map << time_boot_ms;                  // offset: 0
        map << roll;                          // offset: 8
        map << pitch;                         // offset: 12
        map << yaw;                           // offset: 16
        map << roll_speed;                    // offset: 20
        map << pitch_speed;                   // offset: 24
        map << yaw_speed;                     // offset: 28
        map << roll_observed;                 // offset: 32
        map << pitch_observed;                // offset: 36
        map << yaw_observed_mag;              // offset: 40
        map << yaw_observed_rtk;              // offset: 44
        map << roll_obs_sub_pred;             // offset: 48
        map << pitch_obs_sub_pred;            // offset: 52
        map << yaw_obs_sub_pred;              // offset: 56
        map << gyro_x_bia;                    // offset: 60
        map << gyro_y_bia;                    // offset: 64
        map << gyro_z_bia;                    // offset: 68
        map << ba_x;                          // offset: 72
        map << ba_y;                          // offset: 76
        map << ba_z;                          // offset: 80
        map << ba_x_obs;                      // offset: 84
        map << ba_y_obs;                      // offset: 88
        map << ba_z_obs;                      // offset: 92
        map << ba_x_bia;                      // offset: 96
        map << ba_y_bia;                      // offset: 100
        map << ba_z_bia;                      // offset: 104
        map << bm_x;                          // offset: 108
        map << bm_y;                          // offset: 112
        map << bm_z;                          // offset: 116
        map << bm_x_obs;                      // offset: 120
        map << bm_y_obs;                      // offset: 124
        map << bm_z_obs;                      // offset: 128
        map << bm_x_bia;                      // offset: 132
        map << bm_y_bia;                      // offset: 136
        map << bm_z_bia;                      // offset: 140
        map << time_used;                     // offset: 144
        map << reserve1;                      // offset: 148
        map << reserve2;                      // offset: 152
        map << reserve3;                      // offset: 156
        map << reserve4;                      // offset: 160
        map << reserve5;                      // offset: 164
        map << reserve6;                      // offset: 168
        map << reserve7;                      // offset: 172
        map << reserve8;                      // offset: 176
        map << reserve9;                      // offset: 180
        map << static_flag;                   // offset: 184
    }

    inline void deserialize(mavlink::MsgMap &map) override
    {
        map >> time_boot_ms;                  // offset: 0
        map >> roll;                          // offset: 8
        map >> pitch;                         // offset: 12
        map >> yaw;                           // offset: 16
        map >> roll_speed;                    // offset: 20
        map >> pitch_speed;                   // offset: 24
        map >> yaw_speed;                     // offset: 28
        map >> roll_observed;                 // offset: 32
        map >> pitch_observed;                // offset: 36
        map >> yaw_observed_mag;              // offset: 40
        map >> yaw_observed_rtk;              // offset: 44
        map >> roll_obs_sub_pred;             // offset: 48
        map >> pitch_obs_sub_pred;            // offset: 52
        map >> yaw_obs_sub_pred;              // offset: 56
        map >> gyro_x_bia;                    // offset: 60
        map >> gyro_y_bia;                    // offset: 64
        map >> gyro_z_bia;                    // offset: 68
        map >> ba_x;                          // offset: 72
        map >> ba_y;                          // offset: 76
        map >> ba_z;                          // offset: 80
        map >> ba_x_obs;                      // offset: 84
        map >> ba_y_obs;                      // offset: 88
        map >> ba_z_obs;                      // offset: 92
        map >> ba_x_bia;                      // offset: 96
        map >> ba_y_bia;                      // offset: 100
        map >> ba_z_bia;                      // offset: 104
        map >> bm_x;                          // offset: 108
        map >> bm_y;                          // offset: 112
        map >> bm_z;                          // offset: 116
        map >> bm_x_obs;                      // offset: 120
        map >> bm_y_obs;                      // offset: 124
        map >> bm_z_obs;                      // offset: 128
        map >> bm_x_bia;                      // offset: 132
        map >> bm_y_bia;                      // offset: 136
        map >> bm_z_bia;                      // offset: 140
        map >> time_used;                     // offset: 144
        map >> reserve1;                      // offset: 148
        map >> reserve2;                      // offset: 152
        map >> reserve3;                      // offset: 156
        map >> reserve4;                      // offset: 160
        map >> reserve5;                      // offset: 164
        map >> reserve6;                      // offset: 168
        map >> reserve7;                      // offset: 172
        map >> reserve8;                      // offset: 176
        map >> reserve9;                      // offset: 180
        map >> static_flag;                   // offset: 184
    }
};

} // namespace msg
} // namespace fppa
} // namespace mavlink
